<?php
/**
* 
*/
class LoginController extends CommonController
{
	public function Index(){
		include $this->display('login.html');
	}
	//登录
	public function Check(){
		$user_name		= isset($_POST['user_name']) ? addslashes(trim($_POST['user_name'])) : '';
		$user_pwd		= isset($_POST['user_pwd']) ? addslashes(trim($_POST['user_pwd'])) : '';
		if (empty($user_name)) {
			$this->msg('请填写登录名');
		}
		if (empty($user_pwd)) {
			$this->msg('登录密码不能为空。');
		}
		$vo = $this->db->table("@_admins")->where("admin_name='$user_name'")->find();
		if (empty($vo)) {
			$this->msg('用户名错误。');
		}
		if ($vo['admin_pwd'] != md5($user_pwd)) {
			$this->msg('用户密码错误。');
		}
		$_SESSION['user_name']	= $user_name;
		$_SESSION['user_id']	= $vo['id'];
		$result['status']	= 1;
		echo json_encode($result);
	}
	
	public function Out() {
		session_destroy();
		$this->msg('退出成功');
	}
	
}
?>